package com.homework2;

import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;

public class practice2 {
    public static void main(String[] args) {
        String[] strs = {"12345","67891","12347809933","98765432102","67891","12347809933"};

        LinkedList<String> llist = new LinkedList<>();

        for (String str : strs) {
            llist.add(str);
        }

        System.out.println("去重前：");
        System.out.println(llist);
        System.out.println("=====================================分割线====================================");
        LinkedHashSet<String> lset = new LinkedHashSet<>();
        lset.addAll(llist);
        llist.clear();
        llist.addAll(lset);

        //迭代器
        System.out.println("迭代器遍历");
        Iterator<String> it = llist.iterator();
        while (it.hasNext()) {
            String next =  it.next();
            System.out.print(next + " ");
        }
        System.out.println();
        System.out.println("=====================================分割线====================================");
        //增强for
        System.out.println("增强for");
        for (String s : llist) {
            System.out.print(s + " ");
        }

    }
}
